/*
 * 
 *后台目标管理弹出框
 * */
var target_review=function(the_target_id,the_id,img,user_id,user_name,style){
	$('#'+the_id).append('<div class="dialog"></div><div class="my_dialog" style="top:10%"></div>');
	$('#'+the_id+' div.my_dialog:eq(0)').append('<h4>目标详情</h4><i class="fa fa-times"></i><div class="target_dialog" style="padding: 0.5em 1em 2em 0.5em;background:white"></div>');
    var detail_share = [[ "target_id","target_describe","target_source", "target_sign" ],
		              [ "序号", "描述", "相关资料", "签到次数" ] ];
    var the_url='/College/jsp/occupation_evaluation/target_dialog.json';
	 $.ajax({
		 url:the_url,
		 data:{param1:the_target_id},
		 type:'post'
	 }).done(function(data){
		 var img='';
		 if(style=='1')
			 $('#'+the_id+'  div.my_dialog:eq(0) div.target_dialog').append('<div style="text-align:right;padding:0.5em 0;border-bottom: 1px dotted #b7b6b6;">'+
					   '<input type="radio" name="review" value="1" checked="checked"> 通过  &nbsp&nbsp<input type="radio" value="-1" name="review" style="margin-left:0.5em"> 不通过'+
					   '<button class="make_sure" style="margin-right:2.5em;margin-left: 2em;margin-top:-0.2em">提交</button></div><h3 style="width:100%">'+data.target+'</h3>');
		 else if(style=='-1')
			 $('#'+the_id+'  div.my_dialog:eq(0) div.target_dialog').append('<div style="text-align:right;padding:0.5em 0;border-bottom: 1px dotted #b7b6b6;">'+
					   '<input type="radio" name="review" value="1"> 通过  &nbsp&nbsp<input type="radio" value="-1" name="review" style="margin-left:0.5em" checked="checked"> 不通过'+
					   '<button class="make_sure" style="margin-right:2.5em;margin-left: 2em;margin-top:-0.2em">提交</button></div><h3 style="width:100%">'+data.target+'</h3>');
		 else
			 $('#'+the_id+'  div.my_dialog:eq(0) div.target_dialog').append('<div style="text-align:right;padding:0.5em 0;border-bottom: 1px dotted #b7b6b6;">'+
					   '<input type="radio" name="review" value="1"> 通过  &nbsp&nbsp<input type="radio" value="-1" name="review" style="margin-left:0.5em"> 不通过'+
					   '<button class="make_sure" style="margin-right:2.5em;margin-left: 2em;margin-top:-0.2em">提交</button></div><h3 style="width:100%">'+data.target+'</h3>');
		 $('#'+the_id+'  div.my_dialog:eq(0) div.target_dialog').append('<p><font size="3" >描述：</font>'+data.describe+'</p><span id="toggle_article" >展开全文</span>');
		 if(data.sign_count!='0'){
		  for(var i=0;i<data.sign_img.length;i++)
			  img+='<img src="'+data.sign_img[i]+'"/>'
		  $('#'+the_id+'  div.my_dialog:eq(0) div.target_dialog').append('<p><font size="3" >今日签到：</font>'+img+'...共'+data.sign_count+'人</p>');
		 }
		 $('#'+the_id+'  div.my_dialog:eq(0) div.target_dialog').append('<font size="3" style="width:100%;margin-left:1.5em">目标分解：</font><div style="margin:0.2em 1.5em;width:calc(100% - 3em);"><table id="dialog_table"></table></div>');
		 $('div#'+the_id).show('slow');
		 var the_colum= detail_share;
					table("dialog_table",data.table,the_colum, false,150);
					$('div.my_dialog span#toggle_article').click(function(){
						$(this).text()=='展开全文'? $(this).text('收起').prev().css('height','auto')
								:$(this).text('展开全文').prev().css('height','2.4em');
					});
					$('div.my_dialog:eq(0) button.make_sure').unbind('click').click(function(){
						 if(typeof($('.my_dialog input[name="review"]:checked').val())=="undefined")
							 win.alert("系统提示","并未进行任何操作，无法提交！");
						 else{
   	    				    $.ajax({
		    		    	   url:'',
		    		    	   data:{param1:user_id,param2:the_target_id,param3:$('input[name="review"]:checked').attr('value')},
		    		    	   type:'post',
		    		    	   success:function(){
		    		    		   win.alert("系统提示","操作成功！");
		    		    		   $('div#'+the_id).hide('fast');
		    		    		   $('#the_table').bootstrapTable('refresh',{
		    							url:'../../jsp/target/target_review.json? param2='+$('div.points_buttons button.selected').attr('value')+' &param1='+user_id
		    						});
		    		    	   }
		    		           });
						   $('div#'+the_id).empty(); 
						   }
					});
					$('div.my_dialog:eq(0) i.fa-times').click(function(){
						$('div#'+the_id).hide('fast');
						$('div#'+the_id).empty();
					});
					
	 });
};
function table(id, data,colums, pagination,height) {
	var colum = [];
	for (var i = 0; i < colums[0].length; i++)
    		   colum[i]={field:colums[0][i],title:colums[1][i],valign:"middle",align:"center"};
	$('#' + id).bootstrapTable({
		columns : colum,
		height:height,
		data : data,
		pagination : pagination,
		search : false,
		searchOnEnterKey : true,
		locale : 'zh-CN'
	});		
};

